﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Model;
using System.Text.RegularExpressions;
using University.Workshop.DataAccess;
using System.Globalization;

namespace University.Workshop.Business
{
    public static class UserCancelAccountManager
    {
        public static User CancelUserAccount(String email,String password)
        {
            if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
            {
                throw new ValidationException("All fields are required");
            }
            User existingUser = UserDataAccess.UserExists(email,password.GetHashCode().ToString(CultureInfo.InvariantCulture));
            if (existingUser == null)
            {
                throw new BusinessException("Incorrect Password");
            }
            UserDataAccess.CancelUserAccount(existingUser,AccountState.Inactive);
            return existingUser;


            
        }
        public static void ReactiveUserAccount(User user)
        {
            if (user != null)
                UserDataAccess.ReactiveUserAccount(user, AccountState.Active);  
        }
    }
}
